package com.alibaba.nacos.config.server.jpa.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * @author
 * @date 2020-03-08 23:31
 *
 */
@Entity
@Table(name = "NACOS_ROLES",uniqueConstraints = {
    @UniqueConstraint(name = "IDX_USER_ROLE", columnNames = {"USERNAME", "ROLE"})
})
public class RolesEntity extends AbstractEntity {

    private static final long serialVersionUID = 1L;

    public RolesEntity () {}

    public RolesEntity(String role, String username) {
        this.role = role;
        this.username = username;
    }

    @Column(name = "ROLE", nullable = false)
    private String role;

    @Column(name = "USERNAME", nullable = false)
    private String username;

    public RolesEntity setRole(String role){
        this.role = role;
        return this;
    }

    public String getRole(){
        return role;
    }

    public RolesEntity setUsername(String username){
        this.username = username;
        return this;
    }

    public String getUsername(){
        return username;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("RolesEntity = {");

        if (role != null){
            sb.append("role = ").append(role).append(", ");
        }
        if (username != null){
            sb.append("username = ").append(username);
        }

        sb.append("}");
        return sb.toString();
    }

}
